package controller

/**
 * @Author huchao
 * @Description //TODO 定义业务状态码
 * @Date 22:11 2022/2/10
 * 注：此页的错误码用于 返回请求 中 携带
 **/

type StatusCode int64

const (
	CodeSuccess         StatusCode = 1000
	CodeInvalidParams   StatusCode = 1001
	CodeUserExist       StatusCode = 1002
	CodeUserNotExist    StatusCode = 1003
	CodeInvalidPassword StatusCode = 1004
	CodeServerBusy      StatusCode = 1005

	CodeInvalidToken      StatusCode = 1006
	CodeInvalidAuthFormat StatusCode = 1007
	CodeNotLogin          StatusCode = 1008
)

var msgFlags = map[StatusCode]string{
	CodeSuccess:         "success", // 等价于 === 1000:"success"
	CodeInvalidParams:   "请求参数错误",
	CodeUserExist:       "用户名重复",
	CodeUserNotExist:    "用户不存在",
	CodeInvalidPassword: "用户名或密码错误",
	CodeServerBusy:      "服务繁忙",

	CodeInvalidToken:      "无效的Token",
	CodeInvalidAuthFormat: "认证格式有误",
	CodeNotLogin:          "未登录",
}

func (statusCode StatusCode) Msg() string {
	msg, ok := msgFlags[statusCode]
	if ok {
		return msg
	}
	return msgFlags[CodeServerBusy]
}
